package com.econ.powercloud.ems.service.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.econ.powercloud.ems.dal.entity.EmsModelUse;
import com.econ.powercloud.ems.dal.mapper.EmsModelUseMapper;
import com.mysql.cj.util.StringUtils;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class EmsModelUseDAO extends ServiceImpl<EmsModelUseMapper, EmsModelUse> {

    public int deleteByDateId(String date){
        LambdaQueryWrapper<EmsModelUse> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(!StringUtils.isNullOrEmpty(date), EmsModelUse::getDateId,date);
        return this.baseMapper.delete(lambdaQueryWrapper);
    }

    public List<EmsModelUse> selectByTime(String yesterday){
        LambdaQueryWrapper<EmsModelUse> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(!StringUtils.isNullOrEmpty(yesterday), EmsModelUse::getDateId,yesterday);
        return this.baseMapper.selectList(lambdaQueryWrapper);
    }

}
